#!/bin/bash
# 阿里云私有仓库发布脚本
# author guyadong
# 1.在当前项目中调用，可以不用输入任何参数、
# 2.通过参数$1指定项目地址

# 项目所在文件文件，默认为当前路径,如果提供了$1参数则用$1替代之
prj_folder=$(pwd -P)
## 判断是否提供了项目地址参数
[ "x$1" != "x" ] && [   -d "$1" ] && prj_folder=$1 && shift
## 判断是否为maven项目并有git版本控制
[ ! -f "$prj_folder/pom.xml" ] && echo "$prj_folder is not maven project folder" && exit 255
[ ! -d "$prj_folder/.git"  ] && echo "$prj_folder is not git control project " && exit 255

pushd $prj_folder 1>/dev/null || exit 
mvn -Dmaven.test.skip clean source:jar install \
    org.apache.maven.plugins:maven-deploy-plugin:2.8:deploy \
    -DaltReleaseDeploymentRepository=rdc-releases::default::https://packages.aliyun.com/maven/repository/2097834-release-WG4jQB/ \
    -DaltSnapshotDeploymentRepository=rdc-snapshots::default::https://packages.aliyun.com/maven/repository/2097834-snapshot-p3z4YQ/ $*

popd 1>/dev/null